package rtda

import "gvm/rtda/heap"

type LocalVars struct {
	heap.Slots
}

func NewLocalVars(maxLocals uint) *LocalVars {
	if maxLocals > 0 {
		return &LocalVars{make([]heap.Slot, maxLocals)}

	}
	return nil
}

func (self LocalVars) SetSlot(index uint, slot heap.Slot) {
	self.Slots[index] = slot
}

func (self LocalVars) GetThis() *heap.Object {
	return self.Slots.GetRef(0)
}

func (self LocalVars) GetBoolean(index int) bool {
	flag := self.GetInt(uint(index))
	if flag == 0 {
		return false
	}
	return true
}
